package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * 攻略分类
 */
@Getter
@Setter
@JsonIgnoreProperties("handler")//转成json的时候忽略序列化该属性
public class StrategyCatalog extends BaseDomain{

    private String name;

    private Strategy strategy;

    private Integer sequence;

    private Boolean state=false;
    //关联文章的集合
    private List<StrategyDetail> details=new ArrayList<>();

    public String getStateName(){
        String msg="禁用";
        if(this.state){
            msg="启用";
        }
        return msg;
    }
    public String getJson(){
        HashMap map = new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        map.put("sequence",sequence);
        map.put("state",state);
        if(strategy!=null){
        map.put("strategyId", strategy.getId());
        map.put("strategyTitle", strategy.getTitle());
        }
        return JSONUtil.toJSONString(map);
    }

}